/*
 *    Copyright 2008 Lammert Westerhoff
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.googlecode.maven.plugins.dependencyconflicts;

import java.util.HashSet;
import java.util.Set;

import org.apache.maven.shared.dependency.tree.DependencyNode;

/**
 * An implementation of the {@link DependencyConflictsResolver} that uses a
 * {@link DependencyConflictsResolverNodeVisitor} to visit the nodes in order to resolve the dependency conflicts.
 * 
 * @author Lammert Westerhoff
 */
public class DefaultDependencyConflictsResolver
    implements DependencyConflictsResolver
{

    /**
     * Construct a <code>DefaultDependencyConflictsResolver<code>.
     */
    public DefaultDependencyConflictsResolver()
    {
        super();
    }

    /*
     * (non-Javadoc)
     * @see
     * com.googlecode.maven.plugins.dependencyconflicts.DependencyConflictsResolver#resolve(org.apache.maven.project
     * .MavenProject, org.apache.maven.artifact.repository.ArtifactRepository)
     */
    @Override
    public DependencyConflicts resolve( final DependencyNode rootNode )
    {
        final Set<DependencyNode> errorNodes = new HashSet<DependencyNode>();
        final Set<DependencyNode> warningNodes = new HashSet<DependencyNode>();
        final Set<DependencyNode> infoNodes = new HashSet<DependencyNode>();

        rootNode.accept( new DependencyConflictsResolverNodeVisitor( errorNodes, warningNodes, infoNodes ) );
        return new DefaultDependencyConflicts( errorNodes, warningNodes, infoNodes );
    }

}
